
<%--
  Created by IntelliJ IDEA.
  User: xinlong
  Date: 2017/10/26
  Time: 15:19
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>分类内容</title>
    <%@include file="/resources/common/head.jsp" %>
    <script src="/resources/script/wetravel.js" type="text/javascript"></script>
    <script src="/resources/css/wetravel.css" type="text/css"></script>
    <script type="text/javascript">
        function addCategory(){
            $("#addCategory").attr("action","/manage/category/${requestScope.parentId}/add/"+$("#categoryName").val());
            $("#addCategory").submit();
        }
    </script>
</head>
<body>

    <ol class="breadcrumb">
        <c:forEach items="${requestScope.parentLink.data}" var="category" varStatus="status">
            <li><a href="/manage/category/${category.id}">${category.name}</a></li>
        </c:forEach>
    </ol>
    <table class="table table-hover">
        <tbody>
            <tr>
                <th>序号</th>
                <th>内容</th>
                <th>动作</th>
            </tr>
            <c:forEach items="${requestScope.serverResponse.data}" var="category" varStatus="status">
            <tr>
                <form action="/manage/category/update" method="post" onsubmit="return confirm('确定提交此次修改吗?')">
                    <input type="hidden" name="categoryId" value="${category.id}">
                    <input type="hidden" name="parentId" value="${category.parentId}">
                    <td style="
                        display:flex;/*给父容器设置*/
                        align-items:center;/*所有子元素都垂直居中了*/
                        padding-top: 14px;
                    ">
                        <span>${category.id}</span>
                    </td>
                    <td><input type="text" name="categoryName" value="${category.name}" class="form-control" placeholder="在此输入修改的节点名"></td>
                    <td>
                        <a class="btn btn-link" href="/manage/category/${category.id}">查看</a>
                        &nbsp;
                        <!-- Deemphasize a button by making it look like a link while maintaining button behavior -->
                        <button type="submit" class="btn btn-link">修改</button>
                        &nbsp;
                        <a class="btn btn-link" href="javascript:if(confirm('确实要删除节点${category.name}及其所有子节点吗?此操作不可恢复'))location='/manage/category/${category.parentId}/delete/${category.id}'">删除节点及所有子节点</a>
                    </td>
                </form>
            </tr>
            </c:forEach>
            <tr>
            <form id="addCategory" method="post">
                <td>&nbsp;</td>
                <td class="form-group">
                    <input type="text" class="form-control" id="categoryName" name="categoryName" placeholder="在此输入添加的节点名">
                </td>
                <td><a class="btn btn-link" href="javascript:addCategory()">添加</a></td>
            </form>
            </tr>
        </tbody>
    </table>

</body>
</html>
